<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

    String type = request.getParameter("type");
    String budgetId = request.getParameter("budgetId");
%>
<html>
<head>
    <title>新建项目</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <link type="text/css" rel="stylesheet" href="/lib/budget/styles.css"/>
    <link rel="stylesheet" href="/css/notice/noticeManagement.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>

    <script type="text/javascript" charset="utf-8" src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/layer/layer.js?20201106"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" ></script>
    <script type="text/javascript" charset="utf-8" src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" ></script>
    <script type="text/javascript" charset="utf-8" src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" ></script>
    <script type="text/javascript" charset="utf-8" src="/js/base/base.js"></script>
    <link type="text/css" rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <script type="text/javascript" charset="utf-8" src="/lib/pagination/js/jquery.pagination.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/js/base/tablePage.js"></script>
    <script type="text/javascript" src="/js/base/base.js"></script>
    <style>
        a{
            text-decoration: none;
        }
        .main{
            /*width: 100%;*/
            margin: 0 auto;
            box-sizing: border-box;
            /*box-shadow: 0px 0px 16px 5px #b8b3b3;*/
            padding: 14px;
            position: relative;
        }
        .nav{
            height: 40px;
            /*border-bottom: 1px solid #000;*/
            font-size: 22px;
            margin-top: -10px;
            font-weight: 400;
        }
        .leftspan{
            display: inline-block;
            width: 156px;
            text-align: right;
            margin-right: 52px;
        }
        ul,li{
            list-style: none;
            margin:12px 0;
            padding: 0;
        }
        input{
            width: 376px;
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 2px;
            padding-left: 6px;
        }
        .inputsmall{
            width: 154px;
            height: 30px;
            text-align: center;
            padding-left: 0px;
        }
        .line{
            height: 2px;
            width: 59px;
            background: #8a8686;
            display: inline-block;
            line-height: 30px;
            position: relative;
            bottom: 4px;
        }
        .btn{
            font-size: 14px;
            background-color: #008cff;
            padding: 4px 18px;
            border-radius: 3px;
            color: #fff;
            cursor:pointer;
        }
        textarea{
            width: 88%;
            height: 100px;
            padding-left: 6px;
        }
        .spspan{
            position: relative;
            bottom: 60px;
        }
        .list{
            text-align: center;
            margin: 60px 0;
        }
        .list span{
            font-size: 18px;
            background-color: #008cff;
            padding: 6px 48px;
            border-radius: 3px;
            color: #fff;
            cursor: pointer;
            margin: 0 3px;
        }
        .uploadbox{
            margin-left: 0px;
            padding-top: 6px;
        }
        select {
            width: 376px;
            height: 30px;
            border: 1px solid #ccc;
            border-radius: 2px;
            padding-left: 6px;
        }
        .mustinput{
            color: red;
            height: 26px;
            line-height: 32px;
            margin-left: 5px;
        }
        a{
            text-decoration: none;
        }
        #u268 table{
            width:80%;
            border-collapse: collapse;
            margin-left: 7px;
            margin: 0 auto;
            table-layout: fixed;

        }
        .fr{
            float: right;
        }
        #u268 th,#u268 td{
            width:30%;
            /*border: 1px solid #666666;*/
            height: 35px;
            font-size: 13px;
            color: #333333;
            text-align: center;
            /*溢出隐藏并显示...*/
            /*word-break: keep-all;*/
            white-space: nowrap;
            text-overflow: ellipsis;
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-align: center;
        }
       /* th{
            background-color: #00ccff;
        }*/
        /*.th1{*/
            /*width: 10%;*/
        /*}*/
        /*.th2{*/
        /*width: 10%;*/
        /*}*/
        /*.th3{*/
        /*width: 155px;*/
        /*}*/
        /*.th4{*/
        /*width: 112px;*/
        /*}*/
        .th5{
        width:50%;
        }
        .th6{
            width: 40%;
        }
        .th7{
        width: 20%;
        }
       /* tr:hover{
            background: #ccc;
            cursor:pointer;
        }*/
        .ri{
            margin: 0 auto;
            font-size: 20px;
            height: 40px;
            border-bottom: 1px solid #000;
            margin-bottom: 16px;
            width: 995px;
        }
        .del{
            text-decoration: none;
        }
        .del:hover{
            color: red;
        }
        .M-box3{
            margin-top: 30px;
           bottom:5px;
           right: 40px;
            text-align: center;
        }


        .jump-ipt{
            width: 38px;
            height: 38px;
            line-height: 38px;
        }
        .p2{
            float: right;
            height: 40px;
            margin-top: 16px;
            margin-right: 278px;
        }

        .quanx{
            cursor:pointer;
            position: relative;
            left: 200px;
        }
        .quanx:hover{
            background-color:#0e6bb7;
            color: #fff;
            cursor:pointer;


        }
        .p2{
            float: right;
            height: 40px;
            margin-top: 16px;
            margin-right: 278px;
        }
        .p2 span{
            font-size: 14px;
            background-color: #2b7fe0;
            padding: 4px 18px;
            border-radius: 3px;
            color: #fff;
            cursor: pointer;
        }
        .p1{

            float: left;
            margin-bottom: 0;
            height: 40px;
            padding-left: 10px;
            font-size: 20px;
            line-height: 40px;
            position: relative;
           /* left: 80px;*/

        }
        .clearfix:after {
            display: table;
            content: " ";
            clear: both;
        }
        .clearfix{
            border-bottom:1px solid #9e9e9e;
            margin-bottom: 16px;
        }
        .content{
            margin-right: 1%;
            margin-top: 1%;
            margin-bottom:50px;
        }

        .foot{
            font-size: 14pt;
            /* margin-top: 58px; */
            width: 100%;
            padding: 5%;
        }
        .foot p{
            /*margin: 20px 0; */
            border-bottom: 1px solid #000;
            height: 40px;
            /* padding-left: 8px; */
        }

        #add{
            font-size: 14px;
            background-color: #2b7fe0;
            padding: 4px 18px;
            border-radius: 3px;
            color: #fff;
            cursor:pointer;
        }
        #clear{
            font-size: 14px;
            background-color: #2b7fe0;
            padding: 4px 18px;
            border-radius: 3px;
            color: #fff;
            cursor:pointer;
        }
        ul,li{
            list-style: none;
        }
        li{
            margin: 25px 0;
        }
        input[type="text"]{
            position: relative;
            margin: 0;
            padding-left: 10px;
            box-sizing: border-box;
            border: 1px solid rgb(221, 221, 221);
            border-image: initial;
            border-radius: 4px;
        }

        .back{
            position:absolute;
            top:10px;
            right:33px;
            color: #fff;
            font-size: 14px;
            cursor:pointer;
            background-color: #0B7CC4;
            width:50px;
            height:20px;
            line-height: 20px;
            padding:5px 10px;
            border-radius: 6px;
            text-align: center;
        }


        /*弹框样式*/

        .td_title1{
            width: 40%;
            height:32px;
        }
        .biginput{
            width: 40%;
            height: 32px;
            font-size: 13px;
        }
        .ml8{
            margin-left:8px;
        }

        input[type="file"]{

            margin-left: 8px;
        }
        #u268 tbody tr:nth-child(2n+1) {
            /* background-color: rgb(246, 247, 249);*/
            background-color: rgb(255, 255, 255);
        }
        #u268 tbody tr:nth-child(2n) {
            /*background-color: rgb(255, 255, 255);*/
            background-color: rgb(246, 247, 249);
        }
        #uploadTable tr {
            border-width: 1px;
            border-style: solid;
            border-color: rgb(192, 192, 192);
            border-image: initial;
        }
        #uploadTable tr:hover{
            background-color:#d3e6f9;
        }
        .M-box3 .active{
            margin: 0px 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color:#fff;
            text-align:center;
            display: inline-block;
        }
        .M-box3 a{
            margin: 0 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            font-size: 12px;
            display: inline-block;
            text-align:center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #333;
            text-decoration: none;
        }
        .jump-ipt {
            width: 38px;
            height: 38px;
            line-height: 38px;
            text-align: center;
            padding: 0;
        }
        .M-box3 a:hover {
            background: #2b7fe0;
        }

        #itemTable th, #itemTable td ,#u268 th,#u268 td{
            width:30%;
            padding: 0 5px;
            /*border: 1px solid #666666;*/
            height: 40px;
            font-size: 13px;
            line-height: 20px;
            color: #333;
            /*溢出隐藏并显示...*/
            /*word-break: keep-all;*/
            /*white-space: nowrap;*/
            /*text-overflow: ellipsis;*/
            -webkit-box-orient: vertical;
            /*overflow: hidden;*/
            text-align: center;
            border:none;


        }
        #itemTable th,#u268 th{
            color: rgb(47, 92, 143);
            font-size: 13px
        }
        #itemTable tr,#u268 tr{
            border-width: 1px;
            border-style: solid;
            border-color: rgb(192, 192, 192);
            border-image: initial;

        }
        #itemTable tr:nth-child(2n+1),#u268 tr:nth-child(2n+1) {
            background-color: rgb(255, 255, 255)!important;
        }
        #itemTable tr:nth-child(2n),#u268 tr:nth-child(2n) {
            background-color: rgb(246, 247, 249)!important;
        }
        .tableMain table{
            width:80%;
            margin:0 auto;
        }
        .tableMain table tbody td input[type=text]{
            width:44%
        }
        .xmList li{
            margin:13px 0;
            list-style: inside;
            border-bottom:1px solid #eee;
        }
        #uploadTable td:nth-child(4){
            text-overflow: initial!important;
            white-space: normal!important;
            line-height: 21px;
        }
        #u268 table th,#u268 table td{
            text-align: left!important;
        }
        #itemTable td:nth-child(2){
            text-overflow: clip;
            white-space: normal;
            line-height: 20px;
            /*word-break: initial;*/
        }

    </style>
</head>
<body>
<div class="main tableMain">
    <p class="nav">项目预算明细</p>
    <span class="back">关闭</span>
    <table style="width: 60%;margin: 0 auto;">
        <tbody>

        <tr>
            <td class="blue_text" width="22%">
                <p >项目排序号：<b class="red">*</b></p>
            </td>
            <td width="80%" style="text-align: left">
                <input type="text" id="budgetItemNo">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                指标分类：
            </td>
            <td width="80%" style="text-align: left">
                <input type="text" id="quotaClassify">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                项目名称：<b class="red">*</b>
            </td>
            <td width="80%" style="text-align: left">
                <input type="text" id="budgetItemName">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                项目周期：<b class="red">*</b>
            </td>
            <td width="80%" style="text-align: left">
                <span><input type="text" placeholder="请选择日期" id="budgetItemBegindate" class="inputsmall" style="text-align: left;width:19%" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  ></span>
                <span class="">至</span>
                <span><input type="text" placeholder="请选择日期" id="budgetItemEnddate" class="inputsmall" style="text-align: left;width:19%" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  ></span>
            </td>
        </tr>
        <tr>
            <td width="22%" class="blue_text">
                录入时间：
            </td>
            <td width="80%" style="text-align: left">
                <input type="text" placeholder="请选择日期" id="inputTime" style="padding-left: 10px" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  >
            </td>
        </tr>

        <tr>
            <td class="blue_text" width="22%">
                上级项目：
            </td>
            <td width="80%" style="text-align: left">
                <select name="postPriv" class="BigSelect" id="priveItem" disabled>
                    <option value="0">请选择上级项目(不选为一级项目)</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                额度号：<b class="red">*</b>
            </td>
            <td width="80%" class="files" id="files_txt">
                 <%--<span id="lineNum" style="display: none">--%>
                    <%--<span><input type="text" id="lineNo1" disabled style="width: 160px"></span>--%>
                    <%--<span><input type="text" id="lineNo2"  style="width: 210px"></span>--%>
                <%--</span>--%>
                <%--<span id="newLineNum"><input type="text"  id="lineNo3"></span>--%>
                     <span><input type="text" id="lineNo1" disabled ></span>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                项目金额：<b class="red">*</b>
            </td>
            <td width="80%" class="files" id="">
                <span><input type="text"  id="itemMoney"></span>
                <span id="jingao" style="color: #CC2222;font-size: 14px;display: none">只能输入数字</span>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                可用金额：<b class="red">*</b>
            </td>
            <td width="80%" class="files" >
                <span><input type="text"  id="remainingAmount"></span>

            </td>
        </tr>
        <%--<tr class="newmoney" >--%>
            <%--<td class="blue_text" width="20%">--%>
                <%--可用金额：<b class="red">*</b>--%>
            <%--</td>--%>
            <%--<td width="80%" class="files" id="">--%>
                <%--<span><input type="text"  id="kyje"></span>--%>
                <%--<span id="jingao" style="color: #CC2222;font-size: 14px;display: none">只能输入数字</span>--%>
            <%--</td>--%>
        <%--</tr>--%>
        <tr class="newmoney" >
            <td class="blue_text" width="22%">
                预支出金额：<b class="red">*</b>
            </td>
            <td width="80%" class="files" >
                <span><input type="text"  id="allAdvance"></span>
                <span id="jingao" style="color: #CC2222;font-size: 14px;display: none">只能输入数字</span>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                项目负责人：<b class="red">*</b>
            </td>
            <td width="80%" style="text-align: left">
                <input disabled class="td_title1 release1" id="itemManager" type="text" username="">
                <%--<a href="javascript:;" class=" ml8 userPrivAdd  add3" name="orgAdd">添加</a>--%>
                <%--<a href="javascript:;" class=" ml8 userPrivClear  clear3" name="orgClear" style="color: red;">清除</a>--%>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                所属部门：
            </td>
            <td width="80%" style="text-align: left">
                <span><input disabled type="text" id="department"></span>
                <%--<span class=" adddept" style="color: #2b7fe0;cursor:pointer">添加</span>--%>
                <%--<span class=" clear" style="color: red;cursor:pointer">清除</span>--%>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                项目执行人：<b class="red">*</b>
            </td>
            <td width="80%" style="text-align: left">
                <textarea disabled class="td_title1 release1" id="itemExecuter" type="text" username="" style="width: 88%;height:100px"></textarea>
                <%--<a href="javascript:;" class=" ml8 userPrivAdd  add4" name="orgAdd">添加</a>--%>
                <%--<a href="javascript:;" class=" ml8 userPrivClear  clear4" name="orgClear" style="color: red;">清除</a>--%>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                项目描述：
            </td>
            <td width="80%" style="text-align: left">
                <span><textarea name=""  id="itemDesc" style="font-family: '微软雅黑'"></textarea></span>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="22%">
                附件文档：
            </td>
            <td width="80%" style="text-align: left">
                <div class="uploadbox"></div>
            </td>
        </tr>
        <%--<tr>--%>
            <%--<td class="blue_text" width="20%">--%>
                <%--附件上传：--%>
            <%--</td>--%>
            <%--<td width="80%" style="text-align: left;position:relative">--%>

                <%--<span style="color:#2b7fe0;cursor:pointer;"><img src="/img/icon_uplod.png" style="margin-right:5px" alt="">附件上传</span>--%>
                <%--<form id="uploadimgform" style="display: inline-block;" target="uploadiframe"  action="/upload?module=budget"  class="xzbtn" enctype="multipart/form-data" method="post">--%>
                    <%--<input type="file" multiple="multiple" name="file" id="uploadinputimg" class="w-icon5" style="cursor:pointer;position: absolute;top: 6px;opacity: 0;width: 93px;left: 24px;cursor:pointer;">--%>
                <%--</form>--%>

            <%--</td>--%>
        <%--</tr>--%>

        </tbody>
    </table>
    <ul>
        <%--<li>--%>
            <%--<span class="leftspan">项目排序号：<font class="mustinput">*</font></span>--%>

            <%--<span><input type="text" id="budgetItemNo"></span>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">指标分类：<font class="mustinput">&nbsp;</font></span>--%>
            <%--<span><input type="text" id="quotaClassify"></span>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">项目名称：<font class="mustinput">*</font></span>--%>
            <%--<span><input type="text" id="budgetItemName"></span>--%>

        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">项目周期：<font class="mustinput">*</font></span>--%>
            <%--<span><input type="text" placeholder="请选择日期" id="budgetItemBegintime" class="inputsmall" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  ></span>--%>
            <%--<span>至</span>--%>
            <%--<span><input type="text" placeholder="请选择日期" id="budgetItemEndtime" class="inputsmall" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  ></span>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">录入时间：<font class="mustinput">&nbsp;</font></span>--%>
            <%--&lt;%&ndash;<span><input type="text" id="inputTime"></span>&ndash;%&gt;--%>
            <%--<span><input type="text" placeholder="请选择日期" id="inputTime" style="padding-left: 10px" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  ></span>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">所属部门：<font class="mustinput">*</font></span>--%>
            <%--<span><input disabled type="text" id="department"></span>--%>
            <%--<span class="btn adddept">添加</span>--%>
            <%--<span class="btn clear">清除</span>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">额度号：<font class="mustinput">*</font></span>--%>
            <%--&lt;%&ndash;<span><input type="text" id="lineNo"></span>&ndash;%&gt;--%>
            <%--<span><input type="text" id="lineNo1" disabled ></span>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">上级项目：<font class="mustinput">&nbsp;</font></span>--%>
            <%--<select name="postPriv" class="BigSelect" id="priveItem" disabled>--%>
                <%--<option value="0">请选择上级项目</option>--%>
            <%--</select>--%>
        <%--</li>--%>

        <%--<li>--%>

            <%--<span class="leftspan">项目金额：<font class="mustinput">*</font></span>--%>

            <%--<span><input type="text"  id="itemMoney"></span>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">项目执行进度：<font class="mustinput">*</font></span>--%>

            <%--<span><input type="text"  id="itemRate"></span>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">项目负责人：<font class="mustinput">*</font></span>--%>


            <%--<input disabled class="td_title1 release1" id="itemManager" type="text" username="">--%>
            <%--<a href="javascript:;" class=" ml8 userPrivAdd btn add3" name="orgAdd">添加</a>--%>
            <%--<a href="javascript:;" class=" ml8 userPrivClear btn clear3" name="orgClear">清除</a>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan">项目执行人：<font class="mustinput">*</font></span>--%>

            <%--<input disabled class="td_title1 release1" id="itemExecuter" type="text" username="">--%>
            <%--<a href="javascript:;" class=" ml8 userPrivAdd btn add4" name="orgAdd">添加</a>--%>
            <%--<a href="javascript:;" class=" ml8 userPrivClear btn clear4" name="orgClear">清除</a>--%>
        <%--</li>--%>
        <%--<li>--%>
            <%--<span class="leftspan spspan">项目描述：<font class="mustinput">&nbsp;</font></span>--%>
            <%--<span><textarea name=""  id="itemDesc"></textarea></span>--%>

        <%--</li>--%>
        <li>
            <div class="clearfix">
                <p class="p1">项目执行明细</p>
            </div>
            <div>
                <table id="itemTable">
                    <thead>
                        <tr>
                            <th class="" style="width: 80px;">流水号</th>
                            <th class=""  style="width: 150px;">流程名称</th>
                            <th class="">申请时间</th>
                            <th class="" style="width: 90px;">本次支出额度</th>
                            <th class="" style="width: 80px;">预支出金额</th>
                            <th class="" style="width: 70px;">可用金额</th>
                            <th class="" style="width: 100px;">执行人</th>
                            <th class="" style="width: 100px;">执行部门</th>
                            <th class="">状态</th>
                            <th class="">操作</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
                <div id="dbgz_paged" class="M-box3 fr" style="margin-top: 29px;margin-right: 7%;">

                </div>
            </div>
        </li>
        <li>
            <div class="content" style="margin-top: 53px;">
                <div class="clearfix">
                    <p class="p1">修改日志</p>
                </div>

                <div id="u268">
                    <table id="uploadTable">
                        <thead>
                        <tr style="">
                            <th class="th7" style="width:8%">操作人用户</th>
                            <th class="th6" style="width:10%">时间</th>
                            <th class="th4" style="width:5%">类型</th>
                            <th class="th5">备注</th>
                        </tr>
                        </thead>


                        <tbody>

                        </tbody>
                    </table>

                    <div id="dbgz_page" class="M-box3 fr" style="margin-top: 29px;margin-right: 7%;">

                    </div>
                </div>
            </div>
        </li>
    </ul>
</div>
</body>
<script>
    // alert(1)
    $(function () {
        var aTagNumber=1;
        var type = <%=type%>;
        var budgetId = <%=budgetId%>;
        $.ajax({
            type:'get',
            url:'/budget/selAllBudget',
            dataType:'json',
            success:function(res){
                var str='';
                if(res){
                    $.each(res.obj,function(index,res){
                        str+='<option value="'+res.budgetId+'">'+res.budgetItemName+'</option>'
                    });
                    $('select').append(str);

                    // initData();
                }
            }
        });

//        function initData() {
//            $.ajax({
//                type: "get",
//                url: "/budget/selAllBudget",
//                dataType: 'json',
//                success: function (res) {
//                    $("#priveItem option").each(function (){
//                        var value = $(this).val();
//                    if(value == budgetId){
//                        $(this).attr("selected", "selected");
//                    }
//                    });
//                }
//            });
//
//
//        }


        $('.adddept').click(function(){
            dept_id='department';
            $.popWindow("../../common/selectDept?0");
        })


        $('.add2').click(function(){
            layer.open({
                type:1,
                title: ['请选择部门', 'background-color:#2b7fe0;color:#fff;'],
                area: ['600px', '420px'],
                btn: ['导入', '取消'],
                content:'',
                success:function(){

                },
                yes:function(obj){


                }
            })
        })

        $('.add3').click(function(){
            user_id='itemManager';
            $.popWindow("../../common/selectUser");
        })
        $('.add4').click(function(){
            user_id='itemExecuter';
            $.popWindow("../../common/selectUser");
        })
        $('.clear').click(function(){
            $(this).siblings().find('input').removeAttr('deptname').removeAttr('deptno').removeAttr('deptid').val('')
        })
        // 清空人员信息
        $('.clear3').click(function () {
            $('#itemManager').attr("privid", "");
            $('#itemManager').attr("userpriv", "");
            $('#itemManager').val("");
        });
        $('.clear4').click(function () {
            $('#itemExecuter').attr("privid", "");
            $('#itemExecuter').attr("userpriv", "");
            $('#itemExecuter').val("");
        });

        function mustWrite() {
            if ($('#budgetItemNo').val() == "") {
                $.layerMsg({content: '请填写项目排序号！', icon: 2});
                return false;
            }
//            if ($('#quotaClassify').val() == "") {
//                $.layerMsg({content: '指标分类！', icon: 2});
//                return false;
//            }
            if ($('#budgetItemName').val() == "") {
                $.layerMsg({content: '请填写项目名称！', icon: 2});
                return false;
            }
            if ($('#budgetItemBegindate').val() == "") {
                $.layerMsg({content: '请填写开始时间！', icon: 2});
                return false;
            }
            if ($('#budgetItemEnddate').val() == "") {
                $.layerMsg({content: '请填写结束时间！', icon: 2});
                return false;
            }
//            if ($('#inputTime').val() == "") {
//                $.layerMsg({content: '请填写录入时间！', icon: 2});
//                return false;
//            }
            if ($('#budgetItemNo').val() == "") {
                $.layerMsg({content: '请选择所属部门！', icon: 2});
                return false;
            }

            if ($('#lineNo').val() == "") {
                $.layerMsg({content: '请填写额度号！', icon: 2});
               return false;
           }

            /*if ($('#priveItem').val() == "") {
                $.layerMsg({content: '请选择上级项目！', icon: 2});
                return false;
            }*/
            if ($('#itemMoney').val() == "") {
                $.layerMsg({content: '请填写项目金额！', icon: 2});
                return false;
            }
            if ($('#itemRate').val() == "") {
                $.layerMsg({content: '请填写项目执行进度！', icon: 2});
                return false;
            }
            if ($('#itemManager').val() == "") {
                $.layerMsg({content: '请选择项目负责人！', icon: 2});
                return false;
            }
            if ($('#itemExecuter').val() == "") {
                $.layerMsg({content: '请选择项目执行人！', icon: 2});
                return false;
            }

//            if ($('#itemDesc').val() == "") {
//                $.layerMsg({content: '项目描述！', icon: 2});
//                return false;
//            }

        }
        function undefinedData(data) {
            if(data == "undefined"){
                return '';
            }else{
                return data;
            }
        }

        var ajaxPage={
            data:{
                page:1,//当前处于第几页
                pageSize:5,//一页显示几条
                useFlag:true,
                budgetId:budgetId

            },
            page:function () {
                var me=this;
                $.post('/budget/selBudgetLogById',me.data,function (json) {
                    var str='';
                    var arr=json.obj;
                    for(var i=0;i<arr.length;i++){
                        str+= '<tr budgetId="'+arr[i].logId+'">'+
                             '<td title="'+undefinedData(arr[i].userId)+'">'+undefinedData(arr[i].userId)+'</td>'+
                            '<td title="'+undefinedData(arr[i].time)+'">'+undefinedData(arr[i].time).substring(0, undefinedData(arr[i].time).length - 2)+'</td>'+
                            '<td title="'+undefinedData(arr[i].type)+'">'+undefinedData(arr[i].type)+'</td>'+
                            '<td title="'+undefinedData(arr[i].remark)+'">'+undefinedData(arr[i].remark)+'</td>'+
                            '</tr>'
                    }
//                $('table').append(str)
                    $('#u268 table tbody').html(str)
                    me.pageTwo(json.totleNum,me.data.pageSize,me.data.page)
                },'json')
            },
            pageTwo:function (totalData, pageSize,indexs) {
                var mes=this;
                $('#dbgz_page').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    prevContent:'上一页',
                    nextContent:'下一页',
                    jump: true,
                    coping: true,
                    homePage:'',
                    endPage: '',
                    current:indexs||1,
                    callback: function (index) {
                        mes.data.page=index.getCurrent();
                        mes.page();
                    }
                });
            }
        }
        ajaxPage.page();


        var ajaxPageTwo={
            data:{
                page:1,//当前处于第几页
                pageSize:5,//一页显示几条
                useFlag:true,
                budgetId:budgetId

            },
            page:function () {
                var me=this;
                $.post('/budget/selBudgetingProcessByItem',me.data,function (json) {
                    var str='';
                    var arr=json.datas;
//                    console.log(arr)
                    for(var i=0;i<arr.length;i++){
                        str+= '<tr budgetId="'+arr[i].budgetId+'" flowId="'+arr[i].flowId+'" runId="'+arr[i].runId+'">'+
                            '<td title="'+undefinedData(arr[i].runId)+'">'+undefinedData(arr[i].runId)+'</td>'+

                            '<td title="'+undefinedData(arr[i].runName)+'"><a href="javascript:;" class="detail">'+undefinedData(arr[i].runName)+'</a></td>'+
                            '<td title="'+undefinedData(arr[i].applicationDate)+'">'+undefinedData(arr[i].applicationDate)+'</td>'+
                            '<td title="'+undefinedData(arr[i].actualExpenditure)+'">'+undefinedData(arr[i].actualExpenditure)+'</td>'+

                            '<td title="'+undefinedData(arr[i].allAdvance)+'">'+undefinedData(arr[i].allAdvance)+'</td>'+
                            '<td title="'+undefinedData(arr[i].isPayment)+'">'+undefinedData(arr[i].isPayment)+'</td>'+
                            '<td title="'+undefinedData(arr[i].createrName)+'"><span style="color:rgb(43, 127, 224);cursor:pointer"  class="itemPro">'+undefinedData(arr[i].createrName)+'</span></td>'+
                            '<td title="'+undefinedData(arr[i].deptName)+'">'+undefinedData(arr[i].deptName)+'</td>'+
                            '<td title="'+undefinedData(arr[i].setpName)+'">'+undefinedData(arr[i].setpName)+'</td>'+
                            '<td><a href="javascript:;" class="detail">查看详情</a></td>'+
                            '</tr>'
                    }
//                $('table').append(str)
                    $('#itemTable  tbody').html(str)
                    me.pageTwo(json.totleNum,me.data.pageSize,me.data.page)
                },'json')
            },
            pageTwo:function (totalData, pageSize,indexs) {
                var mes=this;
                $('#dbgz_paged').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    prevContent:'上一页',
                    nextContent:'下一页',
                    jump: true,
                    coping: true,
                    homePage:'',
                    endPage: '',
                    current:indexs||1,
                    callback: function (index) {
                        mes.data.page=index.getCurrent();
                        mes.page();
                    }
                });
            }
        }
        ajaxPageTwo.page();

        $('#itemTable').on('click','.detail',function(){
            var  flowId = $(this).parents('tr').attr('flowId')
            var  runId = $(this).parents('tr').attr('runId')
            window.open('/workflow/work/workformPreView?flowId='+flowId+'&tableName=budget&runId='+runId)
        })

        $('#itemTable').on('click','.itemPro',function(){
            var  runId = $(this).parents('tr').attr('runId')
            layer.open({
                type: 1,
                title:['预算项目', 'background-color:#2b7fe0;color:#fff;'],
                area: ['520px', '380px'],
                shadeClose: true, //点击遮罩关闭
                btn: [sure, cancel],
                content:'<span id="protionId">项目列表：</span>'+
                '<ul class="xmList">' +
                '</ul>',
                success:function(){
                    $.ajax({
                        url:'/budget/selAllBudgetFlow',
                        dataType:'json',
                        data:{runId:runId},
                        success:function(res){
                            var data=res.obj;
                            var str = "";
                            for(var i=0;i<data.length;i++){
                                var item = data[i];
                                var lineNo = data[i].lineNo.split(',').join('')
                                str += '<label><li class="lis"><span onmouseenter="biaoqian(this)" onmouseleave="shebiaoqian(this)">'+data[i].budgetItemName+'</span></li></label>'
                            }
                            $('.xmList').html(str)

                        }
                    })
                },


            });
        })




        //删除附件
        $('.uploadbox').on('click','.deImgs',function(){
            var data=$(this).parents('.dech').attr('attachmentUrl');
            var dome=$(this).parents('.dech');
            deleteChatment(data,dome);
        })
        function deleteChatment(data,element){
            layer.confirm('<fmt:message code="workflow.th.que" />？', {
                btn: ['<fmt:message code="global.lang.ok" />','<fmt:message code="depatement.th.quxiao" />'], //按钮
                title:"<fmt:message code="notice.th.DeleteAttachment" />"
            }, function(){

                //确定删除，调接口
                $.ajax({
                    type:'get',
                    url:'../delete',
                    dataType:'json',
                    data:data,
                    success:function(res){
                        if(res.flag == true){
                            layer.msg('<fmt:message code="workflow.th.delsucess" />', { icon:6});
//                                     var file = $('[name="file"]')
//                                     file.after(file.clone().val(""));
//                                     file.remove();
                            element.remove();
                        }else{
                            layer.msg('<fmt:message code="lang.th.deleSucess" />', { icon:6});
                        }
                    }
                });

            }, function(){
                layer.closeAll();
            });
        }
        function inputcheck(name,value) {
            $('#'+name+'').val(value)
        }
        function preveCheck(name,value) {
            $('#'+name+'').html(value)
        }
        if(type==1){
            $('.nav').text('新建预算项目');
            $('#save').click(function(){
                if(mustWrite()==false) {
                    return;
                }
                var attachmentId = []
                var attachmentName = []
                if($('.uploadbox .inHidden')){
                    for(var i=0;i < $('.uploadbox .inHidden').length;i++){
                        attachmentId+=$('.uploadbox .inHidden').eq(i).val()+','
                        attachmentName+=$('.uploadbox ').find('.dech>a').eq(i*aTagNumber).attr('NAME')+'*'
                    }
                }
                var budgetItemNo=$('#budgetItemNo').val();
                var quotaClassify=$('#quotaClassify').val();
                var budgetItemName=$('#budgetItemName').val();
                var budgetItemBegindate=$('#budgetItemBegindate').val();
                var budgetItemEnddate=$('#budgetItemEnddate').val();
                var inputTime=$('#inputTime').val();
                var department=$('#department').attr('deptid');
                var lineNo=$('#lineNo').val();
                var priveItem= $("#priveItem option:checked").val();
                var expenditureRatio=$('#itemMoney').val();
                var itemRate=$('#itemRate').val();
                var itemExecuter=$('#itemExecuter').attr('user_id');
                var itemManager=$('#itemManager').attr('user_id');
                var itemDesc=$('#itemDesc').val();
                var attachmentName=attachmentName;
                var attachmentUrl= attachmentId;
                $.ajax({
                    url:'/budget/addBudgetItem',
                    type:'post',
                    data:{
                        'budgetItemNo':budgetItemNo,
                        'quotaClassify':quotaClassify,
                        'budgetItemName':budgetItemName,
                        'budgetItemBegindate':budgetItemBegindate,
                        'budgetItemEnddate':budgetItemEnddate,
                        'inputTime':inputTime,
                        'department':department,
                        'lineNo':lineNo,
                        'priveItem':priveItem,
                        'itemMoney':itemMoney,
                        'expenditureRatio':expenditureRatio,
                        'itemManager':itemManager,
                        'itemExecuter':itemExecuter,
                        'itemDesc':itemDesc,
                        'attachmentName':attachmentName,
                        'attachmentUrl':attachmentUrl

                    },
                    dataType:'json',
                    success:function(res){
                            if(res.msg=="新建项目重复"){
                                layer.msg("新建项目重复", {
                                    icon: 2,
                                    time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                });
                            }else {
                                layer.msg("新建成功", {
                                    icon: 1,
                                    time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                }, function () {
                                    location.href = "/budget/budgetItemManage"
                                });
                            }
                        }

//                        if(res){
//                            layer.msg("新建成功",{
//                                icon: 1,
//                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
//                            },function(){
//                                location.href="/budget/budgetItemManage"
//                            });
//                        }

//                    }
                })
            })

        }
        if(type==2){

            $('.nav').text('编辑预算项目');
            $.ajax({
                url:'/budget/selBudgetItemById',
                type:'get',
                data:{
                    'budgetId':budgetId
                },
                dataType:'json',
                success:function(res){
                    $("head>title").text("编辑预算项目")
                    var obj=res.object;
                    if(res){
                        inputcheck('budgetItemNo',obj.budgetItemNo);
                        inputcheck('quotaClassify',obj.quotaClassify);
                        inputcheck('budgetItemName',obj.budgetItemName);
                        inputcheck('budgetItemBegindate',obj.budgetItemBegindate);
                        inputcheck('budgetItemEnddate',obj.budgetItemEnddate);
                        inputcheck('inputTime',obj.inputTime);
                        inputcheck('department',obj.deptName);
                        inputcheck('lineNo',obj.lineNo);
                        preveCheck('priveItem>option:selected',obj.priveItem);
                        inputcheck('itemMoney',obj.itemMoney);
                        inputcheck('itemRate',obj.expenditureRatio);
                        inputcheck('itemManager',obj.itemManager);
                        inputcheck('itemExecuter',obj.itemExecuter);
                        inputcheck('itemDesc',obj.itemDesc);
                        inputcheck('remainingAmount',obj.remainingAmount);
                        inputcheck('allAdvance',obj.allAdvance);
//
//                     console.log(obj.priveItem);
                    }
                    }
            })

            $('#save').click(function(){
                if(mustWrite()==false) {
                    return;
                }

                var data = {
                    'budgetId': budgetId,
                    'budgetItemNo': $('#budgetItemNo').val(),
                    'quotaClassify': $('#quotaClassify').val(),
                    'budgetItemName': $('#budgetItemName').val(),
                    'budgetItemBegindate': $('#budgetItemBegindate').val(),
                    'budgetItemEnddate':$('#budgetItemEnddate').val(),
                    'inputTime':$('#inputTime').val(),
                    'department':$('#department').val(),
                    'lineNo':$('#lineNo').val(),
                    'itemMoney':$('#itemMoney').val(),
                    'itemRate':$('#itemRate').val(),
                    'itemExecuter':$('#itemExecuter').val(),
                    'itemManager':$('#itemManager').val(),
                    'itemDesc':$('#itemDesc').val(),
                    'priveItem': $('#priveItem option:checked').text()
                }

                $.ajax({
                    url:'/budget/upBudgetItemById',
                    type:'post',
                    data:data,
                    dataType:'json',
                    success:function(res){
                        if(res){
                            layer.msg("编辑成功",{
                                icon: 1,
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                location.href="/budget/budgetItemManage"
//                                window.location.reload()
                            });
                        }
                    }
                })
            })

        }

        if(type==3){
            var itemDesc=$('#itemDesc').val();
            $('input').attr('disabled',true);
            $('input').attr('placeholder','');
            $('#itemDesc').attr('disabled',true);
            $('.nav').text('项目预算明细');
            $('.btn').remove();
            $('.last').text('附件信息：');
            $('#uploadimgform').remove();
            $('#save').remove();
            $.ajax({
                url:'/budget/selBudgetItemById',
                type:'get',
                data:{
                    'budgetId':budgetId,
                    'str':'项目进度'
                },
                dataType:'json',
                success:function(res){
                    var obj=res.object
                    var lineNo = obj.lineNo.split(',').join('')
                    if(res){
                        inputcheck('budgetItemNo',obj.budgetItemNo);
                        inputcheck('quotaClassify',obj.quotaClassify);
                        inputcheck('budgetItemName',obj.budgetItemName);
                        inputcheck('budgetItemBegindate',obj.budgetItemBegindate);
                        inputcheck('budgetItemEnddate',obj.budgetItemEnddate);
                        inputcheck('inputTime',obj.inputTime);
                        inputcheck('department',obj.deptName);
                        inputcheck('lineNo1',lineNo);
                        preveCheck('priveItem>option:selected',obj.priveItem);
                        inputcheck('itemMoney',obj.itemMoney);
                        inputcheck('itemRate',obj.baiFenBi);
                        inputcheck('itemManager',obj.itemManagerName);
                        inputcheck('itemExecuter',obj.itemExecuterName);
                        inputcheck('itemDesc',obj.itemDesc);
                        inputcheck('allAdvance',obj.allAdvance)
                        inputcheck('remainingAmount',obj.remainingAmount)

                        var str = '';
                        var urlObj = obj.attachmentUrl;
                        var nameObj = obj.attachmentName;
                        var arrList = obj.attachments;
                        if(arrList != undefined && arrList !=""){
                            if(arrList.length>0){
                                for(var i=0;i<arrList.length;i++){
                                    str+='<div class="dech" attachmentUrl="'+arrList[i].attUrl+'" style="display:block;margin:6px 0;"><a class="ATTACH_a" NAME="'+arrList[i].attachName+'" href="<%=basePath %>download?'+encodeURI(arrList[i].attUrl)+'"><img src="/img/attachment_icon.png" style="margin-right:5px" alt="">'+arrList[i].attachName+'</a><img class="deImgs2" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" attachmentName="'+arrList[i].attUrl+'"  class="inHidden" value="'+arrList[i].aid+'@'+arrList[i].ym+'_'+arrList[i].attachId+',"></div>';

                                }
                                $('.uploadbox').html(str);
                            }
                        }

                        if(!(urlObj == undefined || nameObj == undefined)){ // || obj.attachmentName == 'undefined'
                            str+='<div class="dech" attachmentUrl="'+urlObj+'" style="display:block;margin:6px 0;"><a class="ATTACH_a" NAME="'+obj.attachmentName+'" href="<%=basePath %>download?'+encodeURI(urlObj)+'"><img src="/img/attachment_icon.png" style="margin-right:5px" alt="">'+nameObj+'</a><img class="deImgs2" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" attachmentName="'+nameObj+'*"  class="inHidden" value=""></div>';

                        }
                        $('.uploadbox').html(str);
                    }
                }
            })
        }
        $('.back').click(function(){
            location.href="/budget/budgetItemManage"
        })

        $('#uploadinputimg').fileupload({
            dataType:'json',
            done: function (e, data) {
                if(data.result.obj != ''){
                    var data = data.result.obj;
                    var str = '';
                    var str1 = '';
                    for (var i = 0; i < data.length; i++) {
                        var gs = data[i].attachName.split('.')[1];
                        if(gs == 'jsp'||gs == 'css'||gs == 'js'||gs == 'html'||gs == 'java'||gs == 'php' ){
                            str += '';
                            layer.alert('jsp、css、js、html、java文件禁止上传!',{},function(){
                                layer.closeAll();
                            });
                        }else{
                            str+='<div class="dech" attachmentUrl="'+encodeURI(data[i].attUrl)+'" style="display:block;margin:6px 0;"><a class="ATTACH_a" NAME="'+data[i].attachName+'*" href="<%=basePath %>download?'+encodeURI(data[i].attUrl)+'">'+data[i].attachName+'</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" attachmentName="'+data[i].attachName+'*"  class="inHidden" value="'+data[i].aid+'@'+data[i].ym+'_'+data[i].attachId+',"></div>';
                        }
                    }
                    $('.uploadbox').append(str);
                }else{
                    //alert('添加附件大小不能为空!');
                    layer.alert('添加附件大小不能为空!',{},function(){
                        layer.closeAll();
                    });
                }
            }
        });
    })
</script>
</html>
